<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html>
	<head>
		<jsp:include page="../inc.jsp"></jsp:include>
		
		<meta http-equiv="X-UA-Compatible" content="edge" />
		<title>付款结算-付款</title>
		<style>
		  ul,li{
            list-style: none;
        }
        a{
            text-decoration: none;
        }
       /* .controlSize{

            min-height:100px;
            _height:100px;
            padding:0;
        }*/
        .payInformartion{
			width:1100px;
            height:30px;
            padding-left:0px;
           
        }
        .payInformartion li{
          	height:40px;
            line-height: 40px;
            font-size: 14px;
        } 
   		
   		#tb{
   		overflow:hidden;
   		width:90%;
   		}
   		#tb ul{
   		float:left;
   		padding-left:0px;
   		}
   		#tb .list{
   		width:150px;
   		text-align:center;
   		color:#3989c8;
   		}
   		
   		#tb ul li{
   		border:1px solid #dcdcdc;
   		font-size:12px;
   		height:30px;
   		line-height:30px;
   		}
   		#tb .list_li li{
   		  text-align:center;
   		  border-left:none;
   		  padding-left:30px;
   		  padding-right:30px;
   		}
   		.impt{
   		margin-top:5px;
   		margin-bottom:5px;
   		}
   		.impt li{
   		  width:505px;
   		  height:30px;
   		  line-height:30px;
   		}
   		.textbox{
            height: 20px;
            margin: 0;
            padding: 0 2px;
            box-sizing: content-box;
            border: 1px solid #95B8E7;
            vertical-align: middle;

        }
        .blue_btn{
            border: none;
            border-radius: 3px;
            background-color: #3989c8;
            padding: 10px 10px;
            margin-right:5px;
            color:#fff;
        }
        .sub_btn{
        	width:64px;
            border: none;
            border-radius: 3px;
            background-color: #ff8800;
            padding: 6px 6px;
            margin-right:10px;
            color:#fff;
        }
        .cancel_btn{
        	width:64px;
            border: none;
            border-radius: 3px;
            border:1px solid #b5b5b5;
            padding: 6px 6px;
            margin-right:10px;
            color:#333;
        }
        .panel combo-p{
        	position: absolute;
        	bottom:0;
        	
        }
       #tb .list li + li{
   		 border-top:0px;  
   		}
   		#tb .list_li li + li{
   		 border-top:0px;  
   		}
		</style>
		<script type="text/javascript">

		var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
		function closeWin(){
			parent.layer.close(index);
		}
		var dataGridData = {total:0, rows:[]};
		var payDataGrid;
		var payMoney="";
		function fillDataGrid(){
		
		$.ajax({
			type:"get",
			url:'${ctx}/statement/payment/${cashNo}?temp='+Math.random(),
			dataType:'json',
			async:false,
			success:function(data){
				a=data;
				dataGridData.total = data.orderList.length;
				dataGridData.rows = data.orderList;
				
				$("#supplier").text(data.payment.supplier);
				$("#username").text(data.payment.username);
				$("#accountBank").text(CommonConverter.toEmptyString(data.payment.accountBank)); //银行名称
				$("#accountCard").text(CommonConverter.toEmptyString(data.payment.accountCard));
				$("#accountName").text(CommonConverter.toEmptyString(data.payment.accountName));
				$("#cashMoney").text(data.payment.cashMoney);
				$("#createTime").text(data.payment.createTime);
				
				$("#remark").text(CommonConverter.toNullString(data.payment.remark));
				//$("#payMoney").text(data.payMoney);
				//$("#beizhu").text(data.auditRemarks);
				sum = data.sum;
			}
		});
	}
		
		$(function(){
			$("#pssorderNumber").text('${cashNo}');
			fillDataGrid();
			payDataGrid=$("#payMent").datagrid({
				data:dataGridData,
				striped : true,
			   // fit : true,
			   // fitColumns: true,
			    singleSelect : true,
			    method : 'get',
			    showFooter: true,
			    columns:[ [ /*{
			        width : '100',
			        title : 'id',
			        align : 'center',
			        field : 'id',
			        hidden:true
			    },*/{
			        width : '160',
			        title : '平台单号',
			        align : 'center',
			        field : 'orderNumber'
			    },{
			     width : '160',
			     title : '供应商单号',
			     align : 'center',
			     field : 'pssOrderNumber'
			     },{
			        width : '100',
			        title : '供应商/采购商',
			        align : 'center',
			        field : 'act_pay',
			        formatter: function(value,row){
			        	if(row.orderNumber!="总计"){
			        		 return "<span>卖："+CommonConverter.toEmptyString(row.saler)+"</span>"+"<br/>"+"<span>买："+CommonConverter.toEmptyString(row.buyer)+"</span>";
			        	}
			        }
			    },{
			        width : '150',
			        title : '订单金额/人数',
			        align : 'center',
			        field : 'act_sum',
			        formatter:function(value,row){
			        	if(row.orderNumber!="总计"){
			           	 	return "￥"+CommonConverter.toEmptyString(row.unitPrice)+"/"+CommonConverter.toEmptyString(row.purchQuantity)+"人";
			        	}
			        }
			    },{
			        width : '150',
			        title : '支付金额',
			        align : 'center',
			        field : 'sum'
			    },{
			        width : '150',
			        title : '支付日期',
			        align : 'center',
			        field : 'payDate'
			    },{
			        width : '100',
			        title : '订单状态',
			        align : 'center',
			        field : 'orderStatus',
			        formatter: function(value,row){
			        	
			        		switch(row.orderStatus+""){
				                case "0":
				                    return "待支付";
				                    break;
				                case "1":
				                    return "待审核";
				                    break;
				                case "2":
				                    return "待出票";
				                    break;
				                case "3":
				                    return "出票中";
				                    break;
				                case "4":
				                    return "出票成功";
				                    break;
				                case "5":
				                    return "取消";
				                    break;
				            }
			        	
			        }
			    },{
			        width : '100',
			        title : '财务状态',
			        align : 'center',
			        field : 'financeStatus',
			        formatter: function(value,row){
			        	
			        		 switch(row.financeStatus+""){
					            case "1":
									return "收款待审核";
									break;
								case "2":
									return "已收款";
									break;
								case "3": 
									return "待提现";
									break;
								case "4": 
									return "提现待审核";
									break;
								case "5":
									return "提现待支付";
									break;
								case "6":
									return "已付款";
									break;
				            }
			        	
			        }
			    }
			    ] ]
			    
			});
			$('#payMent').datagrid('reloadFooter',[{orderNumber: '总计', sum: sum}]);
			
			$("#submit").click(function(){})
			
		});
		
		
		
		function auditPay(){
			
			//验证付款时间  必填
			var  payTime = $("#paymentTime").val();
			if(payTime == null || payTime == "" || payTime == "undefined"){
				layer.alert('请填写付款时间', {
					  title:'友情提醒',
					  skin: 'layui-layer-lan', //样式类名
					  closeBtn: 0
					}, function(index){
						layer.close(index);
					});
				return;
			}
			
			progressLoad();
			var isValid = $('#dataForm').form('validate');
			if (!isValid) {
				progressClose();
				return;
			}
			
			var param={};//存储所有参数
			var paymentType = $("#paymentType").val();
			var accountBank = $("#accountBank1").val();
			var paymentNo = $("#paymentNo").val();
			var paymentTime = $("#paymentTime").val();
			var paymentRemarks = $("#paymentRemarks").val();
			
			param={"cashNo":"${cashNo}",
					"paymentType":paymentType,
					"accountBank":accountBank,
					"paymentNo":paymentNo,
					"paymentTime":paymentTime,
					"paymentRemarks":paymentRemarks
					};
			//发送ajax请求  
			$.ajax({
				type:"post",
				url:"${ctx}/statement/payStatement?temp="+Math.random(),
				data:"pay="+JSON.stringify(param),
				success:function(data){
					progressClose();
					if(data.success){
						layer.alert('付款成功！',{skin:'layui-layer-lan',title: ['系统提示', 'background-color:#00B2EE; color:#fff;'],closeBtn: 0}, function(index){
							layer.close(index);
							closeWin();
						});
					}else{
						layer.alert("付款失败！");
					}
				},
				error:function(msg){
					progressClose();
					layer.alert("付款失败！");
				}
			});
		}
		</script>
	</head>
	<body style="padding-left:10px;padding-top:0px;">
	<div>
    	<ul class="payInformartion">
        	<li>结算单号:<span id="pssorderNumber"></span></li>
   	 	</ul>
 
            <table id="payMent"></table>
	</div>	
	
	<div id="tb">
		<ul class="list">
			<li>供应商</li>
         	<li>提现申请人</li>
         	<li>申请时间</li>
         	<li>提现金额</li>
         	<li>银行名称</li>
         	<li>持卡人</li>
         	<li>卡号</li>
         	<li>备注</li>
		</ul>
         <ul class="list_li">
         	<li id="supplier"></li>
         	<li id="username"></li>
         	<li id="createTime"></li>
         	<li id="cashMoney"></li>
         	<li id="accountBank"></li>
         	<li id="accountName"></li>
         	<li id="accountCard"></li>
         	<li id="remark"></li>
         </ul>
     </div> 
    <form id="dataForm">
       <table border="0" style="margin-bottom: 50px">
       	<tr>
       		<td align="right"><span style="color:red;">*</span>支付方式：</td>
       		<td>
       		<select id="paymentType"  style="width:300px;height:25px;" class="textbox">
                    <option value="0">现金</option>
                    <option value="1">支票</option>
                    <option value="2">电汇</option>
                    <option value="3">对公汇款</option>
                    <option value="4">对私汇款</option>
                    <option value="5">现金支票</option>
                    <option value="6">转账支票</option>
                </select>
       		</td>
       	</tr>
       	<tr>
       		<td align="right">银行：</td>
       		<td>
       			<select id="accountBank1" style="width:300px;height:25px;" class="textbox">
                    <option value="1">上海浦东发展银行股份有限公司天津科技支行</option>
                </select>
       		</td>
       	</tr>
       	<tr>
       		<td align="right">单号：</td>
       		<td>
       		<input id="paymentNo" style="width:295px;height:20px" type='text' class="easyui-validatebox textbox" data-options="'required':true"/>
       		</td>
       	</tr>
       	<tr>
       		<td align="right"><span style="color:red;">*</span>付款时间：</td>
       		<td>
       		<input id="paymentTime" onfocus="new WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
       				style="width:295px;height:20px;" class="textbox">

       		</td>
       	</tr>
       	<tr>
       		<td align="right">说明：</td>
       		<td>
	       		<textarea id="paymentRemarks" rows="3" cols="70" style="border:1px solid #95B8E7"></textarea>
       		</td>
       	</tr>
       	<tr>
       		<td colspan="2" align="center">
       			<input type="button" value="提交" class="sub_btn" id="submit" onclick="auditPay()"/>
       			<input type="button" value="取消" class="cancel_btn" id="close" onclick="closeWin()"/>
       		</td>
       	</tr>
       </table>
  	 </form>
	</body>
	<script type="text/javascript" src="${ctx}/jslib/layer/layer.js" charset="utf-8"></script>
</html>